import instance from "@/http/index.js";

// 创建产品
export const createProduct = (data) => {
  const { product_id, ...in_memo } = data;
  return instance({
    url: "/pro/createProduct",
    method: "POST",
    data: {
      product_id,
      ...in_memo,
    },
  });
};

// 删除产品
export const deleteProduct = (id) => {
  return instance({
    url: "/pro/deleteProduct",
    method: "POST",
    data: {
      id,
    },
  });
};

// 编辑产品信息
export const editProduct = (data) => {
  const { id, ...product_name } = data;
  return instance({
    url: "/pro/editProduct",
    method: "POST",
    data: {
      id,
      ...product_name,
    },
  });
};

// 获取产品列表信息
export const getProductList = () => {
  return instance({
    url: "/pro/getProductList",
    method: "POST",
  });
};

// 产品申请出库
export const applyOutProduct = (data) => {
  const { id, ...apply_memo } = data;
  return instance({
    url: "/pro/applyOutProduct",
    method: "POST",
    data: {
      id,
      ...apply_memo,
    },
  });
};

// 产品审核列表
export const applyProductList = () => {
  return instance({
    url: "/pro/applyProductList",
    method: "POST",
  });
};
// 对产品进行撤回申请
export const withdrawApplyProduct = (id) => {
  return instance({
    url: "/pro/withdrawApplyProduct",
    method: "POST",
    data: {
      id,
    },
  });
};

// 产品审核
export const auditProduct = (data) => {
  const { id, ...product_out_number } = data;
  return instance({
    url: "/pro/auditProduct",
    method: "POST",
    data: {
      id,
      ...product_out_number,
    },
  });
};

// 通过入库编号对产品进行搜索
export const searchProductById = (product_id) => {
  return instance({
    url: "/pro/searchProductById",
    method: "POST",
    data: {
      product_id,
    },
  });
};

// 通过出库申请编号对产品进行搜索
export const searchProductByApplyId = (product_out_id) => {
  return instance({
    url: "/pro/searchProductByApplyId",
    method: "POST",
    data: {
      product_out_id,
    },
  });
};
// 通过出库编号对产品进行搜索
export const searchProductByOutId = (product_out_id) => {
  return instance({
    url: "/pro/searchProductByOutId",
    method: "POST",
    data: {
      product_out_id,
    },
  });
};

// 获取产品总数
export const getProductLength = () => {
  return instance({
    url: "/pro/getProductLength",
    method: "POST",
  });
};
// 获取出库产品列表
export const auditProductLength = () => {
  return instance({
    url: "/pro/auditProductLength",
    method: "POST",
  });
};
// 获取申请出库产品总数
export const getApplyProductLength = () => {
  return instance({
    url: "/pro/getApplyProductLength",
    method: "POST",
  });
};
// 获取出库产品总数
export const getOutProductLength = () => {
  return instance({
    url: "/pro/getOutProductLength",
    method: "POST",
  });
};
// 监听换页返回数据 产品页面
export const returnProductListData = (pager) => {
  return instance({
    url: "/pro/returnProductListData",
    method: "POST",
    data: {
      pager,
    },
  });
};
// 监听换页返回数据 申请出库页面
export const returnApplyPoductListData = (pager) => {
  return instance({
    url: "/pro/returnApplyPoductListData",
    method: "POST",
    data: {
      pager,
    },
  });
};
// 监听换页返回数据 产品出库页面
export const returnOutPoductListData = (pager) => {
  return instance({
    url: "/pro/returnOutPoductListData",
    method: "POST",
    data: {
      pager,
    },
  });
};
